package Pool;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;

public class Test {
    public static void main(String[] args){
        LinkedBlockingQueue<BaoZi> zt=new LinkedBlockingQueue<>(5);
        Productor p=new Productor(zt);
        ExecutorService pool= Executors.newCachedThreadPool();
        pool.execute(p);
        for (int i=0;i<10;i++){
            Customer c=new Customer(zt,"客人"+(i+1));
            try {
                if (i==4)Thread.sleep(2000);
                if (i==6)Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            pool.execute(c);
        }
    }
}
